<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='党建',active='party'">
<header th:replace="comm/header::headerFragment(${title},${active})"></header>
<link th:href="@{/admin/plugins/tagsinput/jquery.tagsinput.css}" rel="stylesheet"/>
<link th:href="@{/admin/plugins/select2.dist.css/select2-bootstrap.css}" rel="stylesheet"/>
<link th:href="@{/admin/plugins/toggles/toggles.css}" rel="stylesheet"/>
<link th:href="@{/admin/plugins/md/css/style.css}" rel="stylesheet"/>
<link th:href="@{/plugins/dropzone/dropzone.css}" rel="stylesheet"/>
<link th:href="@{/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css}" rel="stylesheet"/>
<link th:href="@{/plugins/nice-validator-0.8.1/jquery.validator.css}" rel="stylesheet"/>
<link rel="stylesheet" th:href="@{/plugins/kkpager/kkpager_blue.css}">

<style>
    #tags_tagsinput {
        background-color: #fafafa;
        border: 1px solid #eeeeee;
    }

    #tags_addTag input {
        width: 100%;
    }

    #tags_addTag {
        margin-top: -5px;
    }

    #dropzone {
        margin-bottom: 3rem;
    }

    .dropzone {
        border: 2px dashed #0087F7;
        border-radius: 5px;
        background: white;
    }

    .dropzone .dz-message {
        font-weight: 400;
    }

    .dropzone .dz-message .note {
        font-size: 0.8em;
        font-weight: 200;
        display: block;
        margin-top: 1.4rem;
    }

    .attach-img {
        width: 100px;
        height: 100px;
        border-radius: 10px;
        box-shadow: 0px 0px 8px #333;
    }

    .attach-text {
        font-size: 12px;
        font-weight: 300;
    }

    .attach-img:hover {
        background-color: #f9f9f9;
    }

    .n-invalid {
        border: 1px solid #c00;
    }

    .tablab{background: #969896}
</style>

<body class="fixed-left">
<div id="wrapper">
    <div th:replace="comm/header::header-body"></div>
    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="form-group">
                    <div class="row">
                        <div class="col-md-6" id="t1"><a class="text-center"><h3>考试</h3></a></div>
                        <div class="col-md-6" id="t2"><a class="text-center"><h3>题目</h3></a></div>
                    </div>
                    <div id="content"></div>
                </div>
                <div class="row" id="examInfo">
                    <div class="col-md-12">
                        <form class="form-horizontal" role="form" id="global-form">
                            <div class="form-group">
                                <label class="col-sm-1 control-label">考试名称</label>
                                <div class="col-md-10">
                                    <input type="text" class="form-control" name="name" id="name" required="required"
                                           aria-required="true" th:value="${buildingExam?.name}"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">总题数</label>
                                <div class="col-md-2">
                                    <input type="text" class="form-control" name="totalNumber" id="totalNumber" required="required"
                                           aria-required="true" th:value="${buildingExam?.totalNumber}"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">总分数</label>
                                <div class="col-md-2">
                                    <input type="text" class="form-control" name="totalPoints" id="totalPoints" required="required"
                                           aria-required="true" th:value="${buildingExam?.totalPoints}"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">及格分</label>
                                <div class="col-md-2">
                                    <input type="text" class="form-control" name="passingGrade" id="passingGrade" required="required"
                                           aria-required="true" th:value="${buildingExam?.passingGrade}"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">日期</label>
                                <div class="col-md-4">
                                    <input type="text" name="startTime" id="startTime"
                                           class="form-control datetimepicker" th:value="${buildingExam?.startTimeStr}">
                                </div>

                                <div class="col-md-4">
                                    <input type="text" name="endTime" id="endTime"
                                           class="form-control datetimepicker" th:value="${buildingExam?.endTimeStr}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">考试说明</label>
                                <div class="col-md-10">
                                    <input type="text" class="form-control" name="remark" id="remark" required="required"
                                           aria-required="true" th:value="${buildingExam?.remark}"/>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="text-center">
                                <button type="submit" class="btn btn-primary waves-effect waves-light">下一步</button>
                                <a th:href="@{/party/exam/list}"
                                   class="btn btn-primary waves-effect waves-light">取消</a>
                            </div>
                            <input name="id" id="id" style="display: none;" th:value="*{buildingExam?.id}">
                            <input name="topicId" id="topicId" style="display: none;">
                        </form>
                    </div>
                </div>
                <div class="row" id="examContent" style="display: none">
                    <div class="col-md-12">
                        <button type="button" class="btn btn-primary btn-lg btn-block" onclick="showModal()">添加考题</button>
                    </div>
                    <div class="col-md-12" style="top: 10px;">
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th class="text-center" width="5%">题号</th>
                                <th class="text-center" width="50%">题目</th>
                                <th class="text-center" width="10%">类型</th>
                                <th class="text-center" width="10%">分数</th>
                                <th class="text-center" width="25%">操作</th>
                            </tr>
                            </thead>
                            <tbody id="list_result">

                            </tbody>
                        </table>
                        <!-- 分页 -->
                        <div id="kkpager"></div>
                    </div>
                    <div class="clearfix"></div>
                    <div class="text-center">
                        <a th:href="@{/party/exam/list}"
                           class="btn btn-primary waves-effect waves-light">保存</a>
                        <a class="btn btn-primary waves-effect waves-light" onclick="showExamInfo()">返回</a>
                    </div>
                </div>
                <div th:replace="comm/footer :: footer-content"></div>
            </div>
        </div>
    </div>
</div>
<!-- Modal -->
<div class="modal fade bs-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">添加题目</h4>
            </div>
            <div class="modal-body">
                <div class="content">
                    <div class="container">
                        <div class="row">
                            <div class="col-md-12">
                                <form class="form-horizontal" role="form" id="exam-form" >
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">考试题目</label>
                                        <div class="col-md-10">
                                            <input type="text" class="form-control" name="title" id="title" required="required"
                                                   aria-required="true" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">考题分数</label>
                                        <div class="col-md-10">
                                            <input type="text" class="form-control" name="grade" id="grade" required="required"
                                                   aria-required="true" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">考题类型</label>
                                        <div class="col-md-10" id="radioChoosen">
                                            <label class="radio-inline">
                                                <input type="radio" name="type" id="type1" value="1" checked="checked" onclick="clearDiv()">单选
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="type" id="type2" value="2" onclick="clearDiv()">多选
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="type" id="type3" value="3" onclick="clearDiv()">判断
                                            </label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">考题答案</label>
                                        <div class="col-md-10">
                                            <div id="answer">
                                            </div>
                                        </div>
                                        <div class="col-md-10">
                                            <button type="button" class="btn-primary" onclick="addAnswer()" id="addAnswers">添加答案</button>
                                        </div>
                                    </div>
                                    <div class="clearfix"></div>
                                    <div class="text-center">
                                        <button type="button" class="btn btn-primary waves-effect waves-light" onclick="saveExamSubjects()">确定</button>
                                        <button type="button" class="btn btn-default waves-effect waves-light" data-dismiss="modal">取消</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:replace="comm/footer :: footer"></div>
<script th:src="@{/plugins/dropzone/dropzone.js}"></script>
<script th:src="@{/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js}"></script>
<script th:src="@{/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.zh-CN.js}"></script>
<script type="text/javascript">
    $('#startTime').datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        minView: "0",
        language: 'zh-CN',
        autoclose: true,
    }).on('change', function () {
        $(this).attr("class", "form-control");
        $(this).siblings('span').html('');
        var startTime = $("#startTime").val();
        $('#endTime').datetimepicker('setStartDate', startTime);

    });
    $('#endTime').datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        minView: "0",
        language: 'zh-CN',
        autoclose: true,
    }).on('change', function () {
        $(this).attr("class", "form-control");
        $(this).siblings('span').html('');
        var endTime = $("#endTime").val();
        $('#startTime').datetimepicker('setEndDate', endTime);
    });
</script>
<script th:src="@{/admin/plugins/tagsinput/jquery.tagsinput.min.js}"></script>
<!-- editor.md -->
<script th:src="@{//cdn.bootcss.com/jquery-toggles/2.0.4/toggles.min.js}"></script>
<script th:src="@{/plugins/nice-validator-0.8.1/jquery.validator.js}"></script>
<script th:src="@{/plugins/nice-validator-0.8.1/zh-CN.js}"></script>
<script th:src="@{/plugins/UMBinding.js}"></script>
<script th:src="@{/plugins/jQuery-ext/serializeObject.js}"></script>
<script th:src="@{/plugins/kkpager/kkpager.min.js}"></script>
<script th:src="@{/js/party/exam/create.js}"></script>
<script th:src="@{/js/common/ArrayUtil.js}"></script>
</body>
</html>